package com.zy.edu.bean;

import java.util.Date;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotations.TableField;
import com.zy.edu.config.SystemParam;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author HuangHaiShui
 * @since 2021-07-17
 */
@Data
public class Course implements Serializable {

    private static final long serialVersionUID = 1L;

    private String id;
    /**
     * 课程名称
     */
    private String name;
    /**
     * 难度：  1-5
     */
    private Integer difficulty;

    /**
     * 课程类别
     */
    private Integer type;
    /**
     * 简介
     */
    private String introduction;
    /**
     * 封面图片url
     */
    @TableField("cover_url")
    private String coverUrl;
    @TableField("create_time")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @JSONField(format="yyyy-MM-dd")
    private Date createTime;
    /**
     * 状态：1 在用；2 停用
     */
    @JSONField(serialize = false)
    private Integer status;

    @TableField("school_id")
    private String schoolId;

    @TableField("juris_id")
    private String jurisId;

    @TableField(exist = false)
    List<CourseChapter> chapterList;

    //数据统计对象
    @TableField(exist = false)
    private StatsInfo statsInfo;

    public String getTypeName(){
        if(!StringUtils.isEmpty(this.type)){
            return SystemParam.COURSE_TYPE.get(this.type);
        }
        return null;
    }

    //校本课程类型 方便显示学校名称
    public String getSchoolName(){
        if(!StringUtils.isEmpty(this.schoolId)){
            return SystemParam.SCHOOLS.get(this.schoolId);
        }
        return null;
    }
}
